#ifndef _ZAB_H_
#define _ZAB_H_

#include "ae.h"
#include <stdio.h>

// the configuration information of a node
typedef struct NODE_INFO_T NODE_INFO_T;

// a zoo contains all nodes.
typedef struct ZOO_CONFIG_T ZOO_CONFIG_T;

// the runtime information of my node
typedef struct NODE_RUNTIME_T NODE_RUNTIME_T;

typedef enum NODE_ROLE_T
{
    NODE_ELECTING,
    NODE_LEADER,
    NODE_FOLLOWER
} NODE_ROLE_T;

NODE_RUNTIME_T* zab_load_node_runtime(const char* zoo_file, const char* runtime_file);
void zab_save_node_runtime(NODE_RUNTIME_T* runtime);

// 1 for success, 0 for failure
int zab_init(NODE_RUNTIME_T* runtime, aeEventLoop* loop);
void zab_destroy(NODE_RUNTIME_T* runtime, aeEventLoop* loop);
// the main entry is aeMain.

#endif
